//
//  BZMatrix.h
//  Bezier
//
//  Created by Isabella Tromba on 12/15/11.
//  Copyright (c) 2011 __MyCompanyName__. All rights reserved.
//

#ifndef Bezier_BZMatrix_h
#define Bezier_BZMatrix_h
#import <QuartzCore/QuartzCore.h>
#define kZoom 2.0
#define kScreenW 1024
#define kScreenH 768
typedef struct _BZMatrix {
    int rowCount, colCount;
    double **data;
} BZMatrix;

int factorial(int n);

#pragma mark -
#pragma mark Matrix Lifecycle
BZMatrix BZCreateMatrix(int rowCount, int colCount);
void BZReleaseMatrix(BZMatrix *mat);
BZMatrix BZCopyMatrix(BZMatrix matrix);
BZMatrix BZMatrixCreateIdentity(int n);

void BZPrintMatrix(BZMatrix matrix, const char *matrixName);

#pragma mark -
#pragma mark Matrix Operations
void BZMatrixColumnReplace(BZMatrix *destMatrix,  BZMatrix sourceMatrix, int colIndexDest, int colIndexSource);
void BZMatrixMultiply(BZMatrix matrixA, BZMatrix matrixB, BZMatrix *matrixOut);
double BZMatrixDeterminant(BZMatrix matrixA);
BZMatrix BZMatrixInverse(BZMatrix matrix);
void BZMatrixScaleRow(BZMatrix *matrix, double scaleFactor, int row);
void BZMatrixSubtractRow(BZMatrix *matrix, BZMatrix sourceMatrix, double scaleFactor,  int rowDest, int rowSource);
BZMatrix BZMatrixAugment(BZMatrix matrix1, BZMatrix matrix2);
BZMatrix BZMatrixSubMatrix(BZMatrix matrix, int rowStart, int colStart, int rowCount, int colCount);

void BZSolveLinearSystem(BZMatrix coeffMatrix, BZMatrix constMatrix, BZMatrix *solutionMatrix);
void BZDrawCurve(BZMatrix controlPointsX, BZMatrix controlPointsY, CGContextRef myContext);
void BZInterpolateCurve(BZMatrix interpolantPointsX, BZMatrix interpolantPointsY, BZMatrix *controlPointsX, BZMatrix *controlPointsY);
void bezierTransformationsToView(double xl,double yl,double *x,double *y);
#endif
